#include "LocalScene.h"
#include "Utils/LogUtil.h"
#include "LocalEntity.h"
#include "Utils/StringUtil.h"
#include "Game/Component/Model.h"
#include "Render/RenderState.h"
#include "Render/Imgui/imgui.h"
#include "Math/Random.h"


void LocalScene::OnInit()
{
	GeometryGenerator geometryGenerator;
	GeometryGenerator::MeshData sphereData = geometryGenerator.CreateSphere(0.3f, 10, 10);
	GeometryGenerator::MeshData cubeData = geometryGenerator.CreateCube(2.f, 2.f, 2.f, 1);

	for (uint32 i = 0; i < 6; ++i)
	{
		for (uint32 j = 0; j < 6; ++j)
		{
			for (uint32 k = 0; k < 6; ++k)
			{
				LocalEntity* sphere = CreateEntity<LocalEntity>();
				sphere->AddComponent<Model>(sphereData);
				sphere->SetColor(glm::vec4(Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f)));
				sphere->GetTransform().SetLocalPosition(glm::vec3(i, j, k) - glm::vec3(3.f, 3.f, 3.f));
				sphere->GetTransform().UpdateMatrices();
			}
		}
	}

	LocalEntity* cube1 = CreateEntity<LocalEntity>();
	cube1->AddComponent<Model>(cubeData);
	cube1->SetColor(glm::vec4(Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f)));
	cube1->GetTransform().SetLocalPosition(glm::vec3(1.5f, 0.f, 0.f));
	cube1->GetTransform().UpdateMatrices();

	LocalEntity* cube2 = CreateEntity<LocalEntity>();
	cube2->AddComponent<Model>(cubeData);
	cube2->SetColor(glm::vec4(Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f), Random64::Rand(0.f, 1.f)));
	cube2->GetTransform().SetLocalPosition(glm::vec3(-1.5f, 0.f, 0.f));
	cube2->GetTransform().UpdateMatrices();
}

void LocalScene::OnExit()
{

}

void LocalScene::OnTick(float deltaTime)
{

}

void LocalScene::OnImgui()
{
	GameScene::OnImgui();

	// ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);

	//ImGui::Begin("ComputeTexture");



	//ImGui::End();
}
